/*
 * Copyright (c) 2009 Enio Perpetuo
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 * 		http://www.apache.org/licenses/LICENSE-2.0
 *  
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 *  
 */
package co.za.gvi.example.send;

import java.util.Date;

import co.za.gvi.smart.VCalendar;
import co.za.gvi.smart.VCard;
import co.za.gvi.transport.MessageProxy;
import co.za.gvi.transport.Transport;

/**
 * @author Enio Perpetuo
 */
public class SmartMessageExample {

	// Please, provide the affiliateCode, authenticationCode and url
	private static String affiliateCode;
	private static String authenticationCode;
	private static String url;
    
    public static void main(String args[]) {
		try {
			// creates a MessageProxy to build the message
			MessageProxy messageProxy = new MessageProxy ();
			
			// creates a VCard
			VCard card = new VCard();
			card.setName("Some Name");
			card.setCellularNumber("08398765437");
			card.setEmail("some.name@server.com");
			
			// creates a VCalendar
			VCalendar calendar = new VCalendar();
			calendar.setSummary("Greate Event");
			calendar.setDescription("You are invited to a greate event");
			calendar.setStartDateTime(new Date());
			
			// add message per recipient
			messageProxy.addRecipient("0851234567", card);
			messageProxy.addRecipient("0851234567", calendar);
			
			// creates a Transport to send the message
			Transport transport = Transport.createTransport(url, affiliateCode, authenticationCode);
			transport.connect();
			transport.send(messageProxy);
			transport.disconnect();
		}catch (Exception e) {
			e.printStackTrace();
		}
	}
}
